package com.xmcowell.sportpacemaster.utils;


import android.app.AlertDialog;
import android.app.ProgressDialog;
import android.content.Context;
import android.view.Gravity;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.xmcowell.sportpacemaster.R;

public class ToastUtil {
    private static Toast toast = null;
    public static int LENGTH_LONG = Toast.LENGTH_LONG;
    private static int LENGTH_SHORT = Toast.LENGTH_SHORT;

    private static AlertDialog refuseDialog;

    public static void show(Context context, String str) {
        toast = Toast.makeText(context, str, LENGTH_SHORT);
        toast.setGravity(Gravity.CENTER, 0, 0);
        TextView tv = (TextView) toast.getView().findViewById(android.R.id.message);
        tv.setTextSize(30);
        toast.show();
    }
    public static void show(Context context, int str) {
        toast = Toast.makeText(context, str, LENGTH_SHORT);
        toast.setGravity(Gravity.CENTER, 0, 0);
        TextView tv = (TextView) toast.getView().findViewById(android.R.id.message);
        tv.setTextSize(30);
        toast.show();
    }

    public static void show(Context context, CharSequence text) {
        toast = Toast.makeText(context, text, Toast.LENGTH_SHORT);
        toast.show();
    }


    public static void showMsg(Context context, CharSequence text) {
        toast = Toast.makeText(context, text, LENGTH_SHORT);
        View view = toast.getView();
        toast.setView(view);
        toast.show();
    }

    public static void showLong(Context context, CharSequence text) {
        toast = Toast.makeText(context, text, LENGTH_LONG);
        View view = toast.getView();
        toast.setView(view);
        toast.show();
        toast.show();
    }

    public static void showImg(Context context, int ImageResourceId,
                               CharSequence text) {
        toast = Toast.makeText(context, text, LENGTH_SHORT);
        toast.setGravity(Gravity.CENTER, 0, 0);
        View toastView = toast.getView();
        ImageView img = new ImageView(context);
        img.setImageResource(ImageResourceId);
        LinearLayout ll = new LinearLayout(context);
        ll.addView(img);
        ll.addView(toastView);
        toast.setView(ll);
        toast.show();
    }

    private static ProgressDialog dialog;


    public static void closeProgressDialog() {
        if (dialog != null && dialog.isShowing()) {
            dialog.dismiss();
        }
    }
}